package seg.appx;

import geom.Line;
import geom.Point;
import geom.Rect;

import java.util.Vector;

import doc.SampledPoint;

public class LineFit {

	private Vector<Point> points;

	public void clearPoints() {
		points.removeAllElements();
	}

	public LineFit() {
		points = new Vector<Point>();
	}

	public void addPoint(Point p) {
		points.add(p);
	}

	public static Line fit(SampledPoint[] ps, int s, int e) {
		Rect bound = Rect.ofBoundBetween(ps, s, e);
		return bound.getMajorAxis();
	}

	public static Line fit(SampledPoint[] ps) {
		return fit(ps, 0, ps.length);
	}
}
